package cn.yunhe.servlet;
/*
 * 郭慧广
 * 食物分页
 *
 * 李非凡更改
 * */

import cn.yunhe.services.FoodFenYeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/FoodFenYeServlet")

public class FoodFenYeServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pageIndex = request.getParameter("pageIndex");//得到当前页
        FoodFenYeService foodFenYeService = new FoodFenYeService();

        int mid = Integer.parseInt(request.getParameter("mid"));
        Map map = foodFenYeService.getFoodPage(pageIndex, mid);

        //存入
        request.setAttribute("mid", mid);
        request.setAttribute("foodList", map.get("foodList"));
        request.setAttribute("pageNum", map.get("pageNum"));
        request.setAttribute("total", map.get("total"));

        request.getRequestDispatcher("list3.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
